package com.example.mycardgame

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import android.widget.Button
import android.widget.EditText

class ModifyInfoActivity : AppCompatActivity() {
    private lateinit var etName: EditText
    private lateinit var etGender: EditText
    private lateinit var etPhone: EditText
    private lateinit var btnSave: Button

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_modify_info)

        etName = findViewById(R.id.et_name)
        etGender = findViewById(R.id.et_gender)
        etPhone = findViewById(R.id.et_phone)
        btnSave = findViewById(R.id.btn_save)

        intent?.run {
            etName.setText(getStringExtra("name"))
            etGender.setText(getStringExtra("gender"))
            etPhone.setText(getStringExtra("phone"))
        }

        btnSave.setOnClickListener {
            setResult(RESULT_OK, Intent().apply {
                putExtra("newName", etName.text.toString())
                putExtra("newGender", etGender.text.toString())
                putExtra("newPhone", etPhone.text.toString())
            })
            finish()
        }
    }
}